{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}
{{> Autogen}}
#pragma once

#include <thrift/lib/cpp2/gen/module_data_h.h>

#include "{{program:include_prefix}}{{program:name}}_types.h"

namespace apache { namespace thrift {
{{#program:enums}}

template <> struct TEnumDataStorage<::{{program:qualified_namespace}}::{{enum:cpp_name}}> {
  using type = ::{{program:qualified_namespace}}::{{enum:cpp_name}};
  static constexpr const std::size_t size = {{(array.len enum:values)}};
  static constexpr std::array<type, size> values = { {
{{#enum:values}}{{!
}}      type::{{enum_value:cpp_name}},
{{/enum:values}}
  }};
  static constexpr std::array<std::string_view, size> names = { {
{{#enum:values}}{{!
}}      "{{enum_value:name}}"sv,
{{/enum:values}}
  }};
};
{{/program:enums}}
{{#program:structs}}
{{#struct:union?}}

template <> struct TEnumDataStorage<{{struct:cpp_fullname}}::Type> {
  using type = {{struct:cpp_fullname}}::Type;
  static constexpr const std::size_t size = {{struct:num_union_members}};
  static constexpr std::array<type, size> values = { {
{{#struct:fields}}{{!
}}      type::{{field:cpp_name}},
{{/struct:fields}}
  }};
  static constexpr std::array<std::string_view, size> names = { {
{{#struct:fields}}{{!
}}      "{{field:name}}"sv,
{{/struct:fields}}
  }};
};
{{/struct:union?}}
{{/program:structs}}
{{#program:structs}}

template <> struct TStructDataStorage<{{struct:cpp_fullname}}> {
  static constexpr const std::size_t fields_size = {{struct:num_fields}};
  static const std::string_view name;
  static const std::array<std::string_view, fields_size> fields_names;
  static const std::array<int16_t, fields_size> fields_ids;
  static const std::array<protocol::TType, fields_size> fields_types;

 private:
  // The following fields describe internal storage metadata, and are private to
  // prevent user logic from accessing them, but they can be inspected by
  // debuggers.
  // -1 if the field has no isset.
  static const std::array<int, fields_size> isset_indexes;
};
{{/program:structs}}

}} // apache::thrift
